package com.itheima.dao;

import com.itheima.domian.User;
import org.apache.ibatis.annotations.*;


import java.util.List;

public interface UserMapper {
   @Select("select*from user")
    List<User> findAll();

   @Delete("delete from user where id=#{id}")
   void delete(int id);

   @Update("update user set username = #{username},password = #{password} where id = #{id}")
   void update(User user);

   @Insert("insert into user  values(#{id},#{username} ,#{password})")
   int  save(User user);


    @Select("select * from user where id=#{id}")
    User findById(int id);


    @SelectKey(keyColumn = "id",keyProperty = "id",resultType = Integer.class,
    before = false,statement = "select last_insert_id()"
    )
    @Insert("insert into user  values(#{id},#{username} ,#{password})")
    int save2(User user);


    @Select("select count(*) from user")
    int count();

}
